package com.example.zzm.yuejian03.Activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.zzm.yuejian03.Adapter.MyshowAdapter;
import com.example.zzm.yuejian03.Bean.PictureBean;
import com.example.zzm.yuejian03.Listener.MyshowListrener;
import com.example.zzm.yuejian03.Model.MyshowModel;
import com.example.zzm.yuejian03.R;

import java.util.List;

public class MypictureActivity extends AppCompatActivity {
    private TextView textView11;
    private RecyclerView recyclerView;
    private int userid;
    private SharedPreferences sp;


    public void  onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.shaitu);
        initView();
        initEvent();
        initDate();
        sp = getSharedPreferences("userInfo",MODE_PRIVATE);

        userid=sp.getInt("user_id",1);
        MyshowModel myModel = new MyshowModel();
        myModel.getshowList(userid,listener);
    }

    MyshowListrener listener = new MyshowListrener() {
        @Override
        public void onResponse(List<PictureBean> beanlist) {
            MyshowAdapter classAdapter = new MyshowAdapter(getApplicationContext(),beanlist);
            recyclerView.setAdapter(classAdapter);
        }

        @Override
        public void onFail(String msg) {

        }
    };
    private void initDate() {
    }

    private void initEvent() {
        textView11.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }

    private void initView() {
        textView11 = (TextView)findViewById(R.id.textView11);
        recyclerView = (RecyclerView)findViewById(R.id.recyclerview);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
    }
}
